{include file="public/layout" /}
<body class="laytp-container">
<div class="layui-card">
    <div class="layui-card-body">
        <blockquote class="layui-elem-quote">
            增加一个钱包的时候，请把“字段名” 和 “钱包名称” 都填好
        </blockquote>
        <form class="layui-form" action="">
            <div class="layui-form-item" style="width: 500px;">
                <table class="layui-table">
                    <tr>
                        <th>钱包名称</th>
                        <th>字段名</th>
                        <th>提现</th>
                        <th>在线充值</th>
                    </tr>
                    {foreach $wallet as $key=>$val}
                        <tr>
                            <td><input type="text" class="layui-input" size="15" name="wallet_name[{$key}]" value="{$val}"></td>
                            <td>{$key}<input type="hidden" size="15" name="wallet_key[{$key}]" value="{$key}"></td>
                            <td>
                                <input type="radio" value="1" name="tx[{$key}]" {if isset($tx[$key]) and $tx[$key] == 1}checked{/if} title="开启" />
                                <input type="radio" value="0" name="tx[{$key}]" {if !$tx[$key]}checked{/if} title="关闭" />
                            </td>
                            <td>
                                <input type="radio" value="1" name="cz[{$key}]" {if isset($cz[$key]) and $cz[$key] == 1}checked{/if} title="开启" />
                                <input type="radio" value="0" name="cz[{$key}]" {if !$cz[$key]}checked{/if} title="关闭" />
                            </td>
                        </tr>
                    {/foreach}
                    {for strat="1" end="10" name="i"}
                        <tr>
                            <td><input type="text" class="layui-input" size="15" name="wallet_name[{$i}]" value=""></td>
                            <td><input type="text" class="layui-input" size="15" name="wallet_key[{$i}]" value=""></td>
                            <td>
                                <input type="radio" value="1" name="tx[{$i}]"  title="开启"  />
                                <input type="radio" value="0" name="tx[{$i}]" checked='checked'  title="关闭" />
                            </td>
                            <td>
                                <input type="radio" value="1" name="cz[{$i}]" title="开启" />
                                <input type="radio" value="0" name="cz[{$i}]" checked='checked' title="关闭" />
                            </td>
                        </tr>
                    {/for}
                </table>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">确认</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script>
    layui.use(['form', 'laydate', 'util'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var util = layui.util;

        // 自定义验证规则
        form.verify({
            pass: [
                /^[\S]{6,12}$/,
                '密码必须6到12位，且不能出现空格'
            ]
        });
        // 提交事件
        form.on('submit(demo1)', function(data){
            var index = layer.load();
            layer.close(index);

            var field = data.field; // 获取表单字段值
            $.ajax({
                type: "POST",
                url: "{:url('wallet')}",
                data: field,
                success: function(res){
                    console.log(res);
                    if(res.status){
                        layer.msg('操作成功');
                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
            return false; // 阻止默认 form 跳转
        });

        // 日期
        laydate.render({
            elem: '#date'
        });


    });
</script>
</body>
</html>